package com.peiqi.aiproject.controller;

import cn.hutool.http.HttpStatus;
import com.peiqi.aiproject.domain.Register;
import com.peiqi.aiproject.domain.vo.ResponseVO;
import com.peiqi.aiproject.service.RegisterService;
import com.peiqi.aiproject.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 注册相关接口
 */
@RestController
@RequestMapping("/register")
public class RegisterController {

    @Resource
    UserService userService;

    /**
     * 注册接口
     * @param registerDTO 登录对象
     * @return String token
     */
    @PostMapping()
    public ResponseVO<String> register(@RequestBody Register registerDTO){
        String token = userService.register(registerDTO);
        return ResponseVO.success(HttpStatus.HTTP_CREATED,token);
    }

}
